<?php
	require_once( "functions/inc_systemFunctions.php" );
	page_header( "Wayne Schlegel Inc. | Route to product", true, "myflight" );
?>
		<style type="text/css">
		#floorMap,
		#selectPosition
		{
		display: none;
		}
		</style>
		<script type="text/javascript">
		$(function()
		{
			$("#showMap").click(function(event){
			event.preventDefault();
			$("#floorMap").slideToggle();
		});
		
		$("#floorMap a").click(function(event) {
			event.preventDefault();
		$("#floorMap").slideUp();
		});
		});

		$(function()
		{
			$("#showPosition").click(function(event){
			event.preventDefault();
			$("#selectPosition").slideToggle();
		});
		
		$("#selectPosition a").click(function(event) {
			event.preventDefault();
		$("#selectPosition").slideUp();
		});
		});

		</script>
		
		
		<?php
			if( $_GET['pid'] != 0 ){
		    	$sql = "SELECT * FROM product WHERE id = " . $_GET['pid'];
		    	$res = mysql_query( $sql );
	    		$row = mysql_fetch_array( $res );
	    	}
	    ?>
		<table class="iTable">
			<tr>
				<td>Your way to <?php echo $row['marketingName']; ?></td>
			</tr>
			
			<tr class="moreInformation">
				<td>
					<a href="#" id="showPosition"><?php
						echo "<small>You are at</small><br />";
						echo "floor " . $_SESSION["current_position"]["floor"] . ", ";
						echo "corridor " . $_SESSION["current_position"]["corridor"] . ", ";
						echo "shelf " . $_SESSION["current_position"]["shelf"];

					?></a>
					<form id="selectPosition" class="iForm" method="post" action="getCurrentPosition.php">
						<label for="quickAccessCode">short-code</label>
						<input style="text-transform: uppercase; border: solid 1px #333333;" type="text" maxlength="4" name="quickAccessCode" id="quickAccessCode" value="" />
						<input type="submit" value="get position">
					</form>
				</td>
			</tr>
			
			<tr>
				<td>
					<?php echo goto( $row['tbl_shelfs_id'], $row['slotInShelf'] ); ?>
				</td>
			</tr>
			
			<tr class="moreInformation">
				<td>
					<a href="#" id="showMap"><img src="images/icons/world.png" align="absmiddle" /> floor map</a>
					<image id="floorMap" width="100%" <?php echo "src=\"".showMapImagePath($row['tbl_shelfs_id'])."\" "?>/>
				</td>
			</tr>
			
			<?php
			if( productOnShoppingList( $_SESSION['user_id'], $_GET['pid'] ) ){
			?>
			<tr class="moreInformation">
				<?php
				if( getShoppingListItemSeenInStore( $_GET['pid'], getShoppingListId( $_SESSION['user_id'] ) ) ){
					echo "<td><a href=\"shoppingListItemToggle.php?pid=" . $_GET['pid'] . "\"><img src=\"/images/icons/seenYes.png\" width=\"40\" align=\"absmiddle\" /> yes, product seen</a></td>";
				} else {
					echo "<td><a href=\"shoppingListItemToggle.php?pid=" . $_GET['pid'] . "\"><img src=\"/images/icons/seenNo.png\" width=\"40\" align=\"absmiddle\" /> no, not seen yet</a></td>";
				}
				?>
			</tr>
			<?php
			}
			?>

			<?php
			if( getNextProductForRouting( $row['id'] ) > 0 ) {
			?>
			<tr class="moreInformation">
				<td>
					<a href="product-showRoute.php?pid=<?=getNextProductForRouting( $row['id'] );?>"><img src="images/icons/next.png" align="absmiddle" /> continue shopping</a>
				</td>
			</tr>
			<?php
			}
			?>
			
			<tr class="moreInformation lastItem">
				<td>
					<a href="product-showRouteToCashDesk.php"><img src="images/icons/shoppingcart.png" align="absmiddle" /> route to cash-desk</a>
				</td>
			</tr>
			
		</table>
<?php
	page_footer();
?>